<?php

namespace App\Http\Resources\CRM;

use App\Enums\TradeStatus;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;

class OrderCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @return array<int|string, mixed>
     */
    public function toArray(Request $request): array
    {
        $data = parent::toArray($request);
        foreach ($data as &$item) {
            $item['status_label'] = TradeStatus::from($item['status'])->label();
        }

        return $data;
    }
}
